import { Service , Inject } from "typedi";
import { HistorySplashEntity } from "../entity/HistorySplashEntity";
import { getRepository,getConnection } from "typeorm";
import {ThinkEntity} from '../entity/ThinkEntity';

@Service()
export class HistoryDao{
    public async getAllHistorySplashDao(): Promise<any> {

        return await     getRepository(HistorySplashEntity)
                            .createQueryBuilder("historySplash")
                            .getMany();
    }


    public async getHistoryThink(think_Page:number,think_Count:number,history_Index:number): Promise<any> {

        return await    getRepository(ThinkEntity)
        .createQueryBuilder('ThinkEntity')
        .where("think_BigTime = :index", { index: history_Index })
        .leftJoinAndSelect('ThinkEntity.think_Time','TimeEntity',)
        .leftJoinAndSelect('ThinkEntity.think_Country','CountryEntity',)
        .orderBy("ThinkEntity.think_LikeType", "DESC")
        .skip(think_Page*think_Count)
        .take(think_Count)
        .getMany()
    }

}